<template>
  <div class="app-container calendar-list-container">
      <!-- filter 条件查询 -->
    <!-- <div class="filter-container" style="display: flex;justify-content:flex-start">
      <el-input clearable @keyup.enter.native="handleFilter" v-model="listQuery.code" style="width: 200px;margin-right:15px;" class="filter-item" placeholder="编码" >
      </el-input>
      <br/>
      <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜索</el-button>
    </div> -->
    <!--表格 -->
    <el-table
      :data="list"
      element-loading-text="给我一点时间"
      v-loading="loading.list"
      border
      fit
      highlight-current-row
      style="width: 100%"
    >
      <el-table-column type="index" label="序号" align="center" width="80px"/>
      <el-table-column prop="equipmentId" label="设备编码" align="center"/>
      <el-table-column prop="smokeStatus" label="烟雾传感器状态" align="center" width="120">
        <template slot-scope="scope">
            <div class="fx">
              {{
                scope.row.smokeStatus == 1
                ? "正常":"异常"
              }}
            </div>
          </template>
      </el-table-column>
      <el-table-column prop="waterTankStatus" label="水箱水位状态" align="center" width="100">
        <template slot-scope="scope">
            <div class="fx">
              {{
                scope.row.waterTankStatus == 1
                ? "正常":"异常"
              }}
            </div>
          </template>
      </el-table-column>
      <el-table-column prop="waterSensorStatus" label="水浸传感器状态" align="center" width="120">
        <template slot-scope="scope">
            <div class="fx">
              {{
                scope.row.waterSensorStatus == 1
                ? "正常":"异常"
              }}
            </div>
          </template>
      </el-table-column>
      <el-table-column prop="updateTime" label="上传时间" align="center" width="120"/>
      <el-table-column prop="fireArea" label="火灾区域" align="center">
        <template slot-scope="scope">
            <div class="fx">
              {{
                scope.row.fireArea == 0
                ? "无火灾":
                scope.row.fireArea == 1
                ? "区域1发生火灾":
                scope.row.fireArea == 2
                ? "区域2发生火灾":
                scope.row.fireArea == 3
                ? "区域1、2发生火灾":
                scope.row.fireArea == 4
                ? "区域3发生火灾":
                scope.row.fireArea == 5
                ? "区域1、3发生火灾":
                scope.row.fireArea == 6
                ? "区域2、3发生火灾":
                scope.row.fireArea == 7
                ? "区域1、2、3发生火灾":
                scope.row.fireArea == 8
                ? "区域4发生火灾":
                scope.row.fireArea == 9
                ? "区域1、4发生火灾":
                scope.row.fireArea == 10
                ? "区域2、4发生火灾":
                scope.row.fireArea == 11
                ? "区域1、2、4发生火灾":
                scope.row.fireArea == 12
                ? "区域3、4发生火灾":
                scope.row.fireArea == 13
                ? "区域1、3、4发生火灾":
                scope.row.fireArea == 14
                ? "区域2、3、4发生火灾":
                scope.row.fireArea == 15
                ? "区域1、2、3、4发生火灾":""
              }}
            </div>
          </template>
      </el-table-column>
      <el-table-column prop="fireSign" label="火灾标志" align="center">
        <template slot-scope="scope">
            <div class="fx">
              {{
                scope.row.fireSign == 0
                ? "正常":"异常"
              }}
            </div>
          </template>
      </el-table-column>
      <el-table-column prop="microSwitch" label="微动开关" align="center">
        <template slot-scope="scope">
            <div class="fx">
              {{
                scope.row.microSwitch == 0
                ? "正常":"异常"
              }}
            </div>
          </template>
      </el-table-column>
      <el-table-column prop="levelWarning" label="液位警告" align="center">
        <template slot-scope="scope">
            <div class="fx">
              {{
                scope.row.levelWarning == 0
                ? "正常":"异常"
              }}
            </div>
          </template>
      </el-table-column>
      <el-table-column prop="selfCheckStatus" label="自检灯状态" align="center">
        <template slot-scope="scope">
            <div class="fx">
              {{
                // scope.row.selfCheckStatus == 0
                // ? "所有灯异常":
                // scope.row.selfCheckStatus == 1
                // ? "自检灯2、3、4发生异常":
                // scope.row.selfCheckStatus == 2
                // ? "自检灯1、3、4发生异常":
                // scope.row.selfCheckStatus == 3
                // ? "自检灯3、4发生异常":
                // scope.row.selfCheckStatus == 4
                // ? "自检灯1、2、4发生异常":
                // scope.row.selfCheckStatus == 5
                // ? "自检灯2、4发生异常":
                // scope.row.selfCheckStatus == 6
                // ? "自检灯1、4发生异常":
                // scope.row.selfCheckStatus == 7
                // ? "自检灯4发生异常":
                // scope.row.selfCheckStatus == 8
                // ? "自检灯1、2、3发生异常":
                // scope.row.selfCheckStatus == 9
                // ? "自检灯2、3发生异常":
                // scope.row.selfCheckStatus == 10
                // ? "自检灯1、3发生异常":
                // scope.row.selfCheckStatus == 11
                // ? "自检灯3发生异常":
                // scope.row.selfCheckStatus == 12
                // ? "自检灯1、2发生异常":
                // scope.row.selfCheckStatus == 13
                // ? "自检灯2发生异常":
                // scope.row.selfCheckStatus == 14
                // ? "自检灯1发生异常":
                // scope.row.selfCheckStatus == 15
                // ? "自检灯正常":""
                scope.row.selfCheckStatus == 15
                ? "正常"
                : scope.row.selfCheckStatus == 7
                ? "第1个灯异常"
                : scope.row.selfCheckStatus == 11
                ? "第2个灯异常"
                : scope.row.selfCheckStatus == 13
                ? "第3个灯异常"
                : scope.row.selfCheckStatus == 14
                ? "第4个灯异常"
                : scope.row.selfCheckStatus == 6
                ? "第1、4个灯异常"
                : scope.row.selfCheckStatus == 9
                ? "第2、3个灯异常"
                : scope.row.selfCheckStatus == 10
                ? "第2、4个灯异常"
                : scope.row.selfCheckStatus == 12
                ? "第3、4个灯异常"
                : scope.row.selfCheckStatus == 1
                ? "第1、2、3个灯异常"
                : scope.row.selfCheckStatus == 2
                ? "第1、2、4个灯异常"
                : scope.row.selfCheckStatus == 4
                ? "第1、3、4个灯异常"
                : scope.row.selfCheckStatus == 8
                ? "第2、3、4个灯异常"
                : scope.row.selfCheckStatus == 0
                ? "所有灯异常" : ''
              }}
            </div>
          </template>
      </el-table-column>
      <el-table-column prop="emergencySwitch" label="应急开关" align="center">
        <template slot-scope="scope">
            <div class="fx">
              {{
                scope.row.emergencySwitch == 0
                ? "正常":"异常"
              }}
            </div>
          </template>
      </el-table-column>
    </el-table>
    <!-- pagination 分页 -->
    <div class="pagination-container">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="listQuery.pageNum "
        :page-sizes="[10, 20, 30, 40,100,300,500]"
        :page-size="listQuery.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
    <!-- 回到顶部 -->
    <BackToTop></BackToTop>
  </div>
</template>
<script>
import { getfirelist } from "@/api/firePush";
import { parseTime, getdTime } from "@/utils/index";

import BackToTop from "@/components/BackToTop";
export default {
  name: "fireRecords",
  components: {
    BackToTop
  },
  data() {
    return {
        // 卡类型
       cardTypeOptions:[
          {
        value:'1',
        label:'城市卡'
        },
        { 
        value:'2',
        label:'设备卡'
        }
      ],
      loading: {
        list: false
      },
      dialog: {
        view: false
      },
      total: 0,
      listQuery: {
        pageNum : 1,
        pageSize: 10,
      },
      list: null,
      downloadLoading: false
    };
  },

  methods: {
  //导出
   //导出
    handleDownload() {
      this.downloadLoading = true
      import('@/vendor/Export2Excel').then(excel => {
        const tHeader = ['序号','昵称','手机号','卡号','可用时长','卡类型','所属城市', '所属设备Id','所属设备编号','是否使用','是否过期','开始时间','结束时间','创建时间']
        const filterVal = [ 'index',	'nickName', 'userPhone','cardNo','time', 'cardTypeInfo', 'address','equipmentId','equipmentNumber', 'isUseInfo', 'isPastInfo','startTime','endTime','ctime']
        const data = this.formatJson(filterVal, this.list)
        excel.export_json_to_excel({
          header: tHeader,
          data,
          filename: '用户月卡列表'
        })
        this.downloadLoading = false
      })
    },
    // 数据筛选
    formatJson(filterVal, jsonData) {
      return jsonData.map(v => filterVal.map(j => {
          return v[j]
      }))
    },
   
    //获取列表
    async getList() {
      this.loading.list = true;
      try {
         //调用服务器接口
        const { data } = await getfirelist({
          ...this.listQuery
        });
        console.log('data',data)
        this.list = data.records
        this.total = data.total;
      } catch (error) {}
      this.loading.list = false;
    },
    //点击查找
    handleFilter() {
      this.listQuery.pageNum  = 1;
      this.getList();
    },
    handleSizeChange(val) {
      this.listQuery.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.pageNum  = val;
      this.getList();
    },
  },

  created() {
    this.getList();
  }
};
</script>
<style lang="scss" scoped>
/deep/ .el-carousel__container {
  height: 500px !important;
}
</style>
